package com.twu.biblioteca;

import java.util.ArrayList;

/**
 * Created by renatagrfarias on 10/2/14.
 */
public class UserRepository {

    private ArrayList<User> users = new ArrayList();

    public void createUsers(){
        createUsers("008-7689", "0987", "James Brown", "jbrown@gmail.com", "9988-4050");
        createUsers("008-9987", "1234", "Elvis Presley", "elvis@gmail.com", "9445-0090");
        createUsers("090-0099", "7766", "Giorgio Moroder", "giomoroder@gmail.com", "9765-8899");
        createUsers("007-7799", "5544", "Aretha Franklin", "afranklin@gmail.com", "9678-1244");
        createUsers("043-9898", "2211", "Nina Simone", "ninasimone@gmail.com", "9333-8798");
    }

    public void createUsers(String libraryNumber, String password, String name, String emailAdress, String phoneNumber) {
        User user = new User(libraryNumber, password, name, emailAdress, phoneNumber);
        users.add(user);
    }

    public User searchUser(String libraryNumber, String password){
        User user = null;
        for(int i=0;i<users.size();i++){
            if(users.get(i).getLibraryNumber().equals(libraryNumber) && users.get(i).getPassword().equals(password)){
                user = users.get(i);
            }
        }
        return user;
    }

    public void showUserInformation(User user){
        System.out.println("Name: " + user.getName() +
                "\nPhone number: " + user.getPhoneNumber() +
                "\nE-mail adress: " + user.getEmail());
    }
}
